from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManager
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

option = Options()
option.add_experimental_option('detach', True)

#自动获取和当前浏览器匹配的webdriver
driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()), options=option)

try:
    driver.get('https://web.txcs.tmall.com/login?from=https%3A%2F%2Fweb.txcs.tmall.com%2F')

    iframe_locator = driver.find_element(By.XPATH,'//iframe[@id="alibaba-login-box"]')
    driver.switch_to.frame(iframe_locator)

    inputStr = driver.find_element(By.XPATH,'//div/div/div[2]/div/form/div/div/input')
    inputStr.send_keys('6666')

except Exception as e:
    print(f"Error occurred: {e}")